﻿<%@ Page Title="Анализ :: Настройки" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Setup.aspx.cs" Inherits="Analysis.Setup" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        var departNameOld = '';
        var saleChannelNameOld = '';
        var storePointNameOld = '';

        window.onbeforeunload = function (e) {
            var departNameValue = GetTextBoxValues("depart_name");
            var saleChannelNameValue = GetTextBoxValues("salechannel_name");
            var storePointNameValue = GetTextBoxValues("storepoint_name");

            if ((departNameValue != departNameOld) || (saleChannelNameValue != saleChannelNameOld) || (storePointNameValue != storePointNameOld)) {
                var e = e || window.event;
                if (e) e.returnValue = 'На странице есть несохраненные данные, закрытие приведет к их потере. Все равно закрыть страницу?'; //for IE & Firefox
                return 'На странице есть несохраненные данные, закрытие приведет к их потере. Все равно закрыть страницу?'; // for Safari and Chrome
            }
        };

        function GetTextBoxValues(cssName) {
            var result = "";
            $("." + cssName).each(function () {
                result += $(this).val() + ";";
            });
            return result;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page_header">
        <h2><img src="<%=ResolveClientUrl("~") %>images/design/dashboard_tt_icon.png" alt="" title="" /> Настройки</h2>
    </div>

    <div class="page_container">
    <asp:UpdatePanel ID="upDepart" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
                <h3>Должности пользователей в системе</h3>
                <div class="table-responsive">
                    <asp:GridView ID="gridDepart" AutoGenerateColumns="false" runat="server" CssClass="table table-bordered table-hover"
                    AllowPaging="False" PageSize="20" OnRowDataBound="gridDepart_RowDataBound" OnRowCommand="gridDepart_RowCommand" ShowHeader="false">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HiddenField ID="hidDepartId" Value='<%#Eval("DepartId")%>' runat="server" />
                            <asp:TextBox ID="tbDepartName" Text='<%# Eval("DepartName") %>' runat="server" CssClass="form-control depart_name" ValidationGroup="saveDepart" placeholder="Введите название должности"/>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="tbDepartName" runat="server" Text="*" ValidationGroup="saveDepart" CssClass="validation_message" Display="Dynamic" />
                            <asp:RegularExpressionValidator ID="revDepartName" runat="server" ControlToValidate="tbDepartName" Text="Максимальная длина 50 символов" ValidationGroup="saveDepart" CssClass="validation_message" ValidationExpression="^([\S\s]{1,50})$" Display="Dynamic" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton runat="server" ImageUrl="~/images/design/actions_icon/delete_icon.gif" ToolTip="Удалить" 
                                ID="btnDelete" CommandName="MakeDelete" CommandArgument='<%# Eval("DepartId")%>' OnClientClick="if (Page_ClientValidate('saveDepart')) {return confirm('Подтвердите удаление должности');} else {return false;}" ValidationGroup="saveDepart" ClientIDMode="Static" />
                            <asp:ImageButton runat="server" ID="btnUp" CommandName="MoveUp" CommandArgument='<%# Eval("DepartId")%>' ImageUrl="~/images/design/actions_icon/arrow_up_blue.png" ToolTip="Поднять вверх"  ValidationGroup="saveDepart" />
                            <asp:ImageButton runat="server" ID="btnDown" CommandName="MoveDown" CommandArgument='<%# Eval("DepartId")%>' ImageUrl="~/images/design/actions_icon/arrow_down_blue.png" ToolTip="Опустить вниз"  ValidationGroup="saveDepart" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                </asp:GridView>
                </div>

                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnAddDepart" Text="Добавить должность" runat="server" ValidationGroup="saveDepart" onclick="btnAddDepart_Click"/>
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnSaveDepart" Text="Сохранить изменения" runat="server" ValidationGroup="saveDepart" onclick="btnSaveDepart_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>
    </div>
    <div class="page_container">
    <asp:UpdatePanel ID="upSaleChannel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
                <h3>Каналы продаж для ТТ</h3>
                <div class="table-responsive">
                    <asp:GridView ID="gridSaleChannel" AutoGenerateColumns="false" runat="server" CssClass="table table-bordered table-hover"
                    AllowPaging="False" PageSize="20" OnRowDataBound="gridSaleChannel_RowDataBound" OnRowCommand="gridSaleChannel_RowCommand" ShowHeader="false">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HiddenField ID="hidSaleChannelId" Value='<%#Eval("SaleChannelId")%>' runat="server" />
                            <asp:TextBox ID="tbSaleChannelName" Text='<%# Eval("SaleChannelName") %>' runat="server" CssClass="form-control salechannel_name" ValidationGroup="saveSaleChannel" placeholder="Введите название канала"/>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="tbSaleChannelName" runat="server" Text="*" ValidationGroup="saveSaleChannel" CssClass="validation_message" Display="Dynamic" />
                            <asp:RegularExpressionValidator ID="revSaleChannelName" runat="server" ControlToValidate="tbSaleChannelName" Text="Максимальная длина 50 символов" ValidationGroup="saveSaleChannel" CssClass="validation_message" ValidationExpression="^([\S\s]{1,50})$" Display="Dynamic"/>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton runat="server" ImageUrl="~/images/design/actions_icon/delete_icon.gif" ToolTip="Удалить" Style="vertical-align:middle;"
                                ID="btnDelete" CommandName="MakeDelete" CommandArgument='<%# Eval("SaleChannelId")%>' OnClientClick="if (Page_ClientValidate('saveSaleChannel')) {return confirm('Подтвердите удаление канала продаж');} else {return false;}" ValidationGroup="saveSaleChannel" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                </asp:GridView>
                </div>

                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnAddSaleChannel" Text="Добавить канал" runat="server" ValidationGroup="saveSaleChannel" onclick="btnAddSaleChannel_Click"/>
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnSaveSaleChannel" Text="Сохранить изменения" runat="server" ValidationGroup="saveSaleChannel" onclick="btnSaveSaleChannel_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>
    </div>
    <div class="page_container">
    <asp:UpdatePanel ID="upStorePoint" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
                <h3>Форматы торговых точек</h3>
                <div class="table-responsive">
                    <asp:GridView ID="gridStorePoint" AutoGenerateColumns="false" runat="server" CssClass="table table-bordered table-hover"
                    AllowPaging="False" PageSize="20" OnRowDataBound="gridStorePoint_RowDataBound" OnRowCommand="gridStorePoint_RowCommand" ShowHeader="false">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HiddenField ID="hidStorePointId" Value='<%#Eval("StorePointId")%>' runat="server" />
                            <asp:TextBox ID="tbStorePointName" Text='<%# Eval("StorePointName") %>' runat="server" CssClass="form-control storepoint_name" ValidationGroup="saveStorePoint" placeholder="Введите название канала"/>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="tbStorePointName" runat="server" Text="*" ValidationGroup="saveStorePoint" CssClass="validation_message" Display="Dynamic" />
                            <asp:RegularExpressionValidator ID="revStorePointName" runat="server" ControlToValidate="tbStorePointName" Text="Максимальная длина 50 символов" ValidationGroup="saveStorePoint" CssClass="validation_message" ValidationExpression="^([\S\s]{1,50})$" Display="Dynamic"/>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton runat="server" ImageUrl="~/images/design/actions_icon/delete_icon.gif" ToolTip="Удалить" Style="vertical-align:middle;"
                                ID="btnDelete" CommandName="MakeDelete" CommandArgument='<%# Eval("StorePointId")%>' OnClientClick="if (Page_ClientValidate('saveStorePoint')) {return confirm('Подтвердите удаление формата торговой точки');} else {return false;}" ValidationGroup="saveStorePoint" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                </asp:GridView>
                </div>

                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnAddStorePoint" Text="Добавить формат" runat="server" ValidationGroup="saveStorePoint" onclick="btnAddStorePoint_Click"/>
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnSaveStorepoint" Text="Сохранить изменения" runat="server" ValidationGroup="saveStorePoint" onclick="btnSaveStorePoint_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>
    </div>
</asp:Content>
